import { Component } from 'react';
import React from 'react';
import { connect } from 'umi';
import HighPerformCardList from '@/components/HighPerformCardList';
import { PlusOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import APIS from '@/apis';

class TemplateManager extends Component<any> {
  actionRef?: any
  requestGetData(
    current: number,
    pageSize: number
  ) {
    return APIS.CourseAPI.GetTemplateList({ current, pageSize })
  }
  render() {
    return (
      <div>
        <HighPerformCardList
          ref={(ref) => this.actionRef = ref}
          requestGetData={this.requestGetData.bind(this)}
          dataIndexes={{ image: 'courseImg', title: 'courseName', description: 'description' }}
          onClickUpdata={data => this.props.history.push({ pathname: 'create', state: data })}
          handleDelete={id => { return APIS.CourseAPI.DeleteCourse(id) }}
          toolBarRender={() => [
            <Button key="btn" type="primary" onClick={() => this.actionRef?.handleModalVisible(true)}>
              <PlusOutlined /> 新增模板
            </Button>,
          ]}
        ></HighPerformCardList>
      </div>
    );
  }
}

export default connect()(TemplateManager);